package com.ricchieri.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.springframework.cache.annotation.Cacheable;

import com.ricchieri.dao.interf.IScheduleCharterExpenseTypeDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.ScheduleCharterExpenseType;

public class ScheduleCharterExpenseTypeDao extends GenericDao implements IScheduleCharterExpenseTypeDao {
	private static final long serialVersionUID = 1639465882071095940L;

	@Override
	@Cacheable(value="expenseType")
	@SuppressWarnings("unchecked")
	public List<ScheduleCharterExpenseType> getAllExpenseType(BasicFilter filter) {
		Criteria criteria = criteriaAllScheduleCharterExpenseType(filter);
		
		return criteria.list();
	}
	
	private Criteria criteriaAllScheduleCharterExpenseType(BasicFilter filter) {
		return super.criteriaAllBasic(filter, ScheduleCharterExpenseType.class);
	}	
	
	@Override
	protected String getTableName() {
		return "scheduleCharterExpenseType";
	}

	@Override
	public ScheduleCharterExpenseType getScheduleCharterExpenseTypeById(
			BasicFilter expenseTypeFilter) {
		Criteria criteria = criteriaAllScheduleCharterExpenseType(expenseTypeFilter);
		
		return (ScheduleCharterExpenseType) criteria.list().get(0);
	}
}
